<template>
  <div>
    <el-button v-if="show('3')" type="success" icon="el-icon-check" title="提交" size="mini" @click="apply(row)" />
    <el-button v-if="show('4')" type="success" icon="el-icon-check" title="审批" size="mini" @click="approve(row)" />
    <el-button v-if="show('1')" type="primary" icon="el-icon-edit" title="编辑" size="mini" @click="edit(row)" />
    <el-button v-if="show('2')" type="danger" icon="el-icon-delete" title="删除" size="mini" @click="del(row)" />
    <el-button v-if="show('0')" type="warning" icon="el-icon-tickets" title="详细" size="mini" @click="detail(row)" />
  </div>
</template>

<script>

export default {
  name: 'DynamicBtn',
  props: {
    type: {
      type: Array,
      default: []
    },
    row: {
      type: Object,
      required: true
    }
  },
  methods: {
    show(val) {
      const type = this.type
      return type.indexOf(val) >= 0
    },
    apply(obj) {
      this.$emit('apply', obj)
    },
    edit(obj) {
      this.$emit('edit', obj)
    },
    del(obj) {
      this.$emit('del', obj)
    },
    approve(obj) {
      this.$emit('approve', obj)
    },
    detail(obj) {
      this.$emit('detail', obj)
    }
  }
}
</script>

<style scoped>

</style>
